﻿//创建时间: 2010-10-11
//创建作者: 李晓忠
//功能说明: CMS系统 结点附加发布 
//最后修改: 2010-10-11
//最后修改: 2010-12-8 李晓忠 获取信息发布点路径
using System;
using System.Collections.Generic;
using System.Text;


using TRPOP.CMS.Model;
using TRPOP.CMS.DALFactory;
using TRPOP.Common;

namespace TRPOP.CMS.Business
{
    public class NodeAddionalPubManage
    {

        private INodeAddionalPubDAL Idal;
        public NodeAddionalPubManage()
        {
            Idal = DataAccess.CreateNodeAddionalPubDAL();
        }

        #region 保存 Save
        ///	<summary>
        ///	保存
        ///	</summary>
        ///	<param name="NodeAddionalPubInfo"></param>
        ///	<returns>EnumSubmitResult</returns>
        public EnumSubmitResult Save(NodeAddionalPubInfo info)
        {
            return Idal.Save(info);
        }

        #endregion

        #region 获取实体 GetInfoById
        ///	<summary>
        ///	获取实体
        ///	</summary>
        ///	<param name="nodeAddionalPubId"></param>
        ///	<returns>NodeAddionalPubInfo</returns>
        public NodeAddionalPubInfo GetInfoById(int id)
        {
            return Idal.GetInfoById(id);
        }
        #endregion

        #region 删除 DeleteInfoById
        ///	<summary>
        ///	删除
        ///	</summary>
        ///	<param name="id"></param>
        ///	<returns>EnumSubmitResult</returns>
        public EnumSubmitResult DeleteInfoById(int id)
        {
            return Idal.DeleteInfoByIds(id.ToString());
        }
        #endregion

        #region 删除 DeleteInfoByIds
        ///	<summary>
        ///	删除
        ///	</summary>
        ///	<param name="ids"></param>
        ///	<returns>EnumSubmitResult</returns>
        public EnumSubmitResult DeleteInfoByIds(string ids)
        {
            return Idal.DeleteInfoByIds(ids);
        }
        #endregion

        #region 自定义列表（无分页） GetListByCondition
        ///	<summary>
        ///	自定义列表（无分页）
        ///	</summary>
        ///	<param name="topn">前N条，为0时表示所有符合条件的</param>
        ///	<param name="condition">自定义条件，要以And开头</param>
        ///	<param name="orderby">排序，不需要Order by </param>
        ///	<returns>List<NodeAddionalPubInfo></returns>
        public List<NodeAddionalPubInfo> GetListByCondition(int topn, string condition, string orderby)
        {
            return Idal.GetListByCondition(topn, condition, orderby);
        }
        #endregion

        #region 自定义列表（分页） GetListByPager
        ///	<summary>
        ///	自定义列表（分页）
        ///	</summary>
        ///	<returns>List<NodeAddionalPubInfo></returns>
        public List<NodeAddionalPubInfo> GetListByPager(int pageNumber, int pageSize, string condition, string orderby, out int recordCount)
        {
            return Idal.GetListByPager(pageNumber, pageSize, condition, orderby, out  recordCount);
        }
        #endregion

        #region 获取最大Id
        /// <summary>
        /// 获取最大Id
        /// </summary>
        /// <returns></returns>
        public int GetMaxId()
        {
            return Idal.GetMaxId();
        }
        #endregion


        #region 获取信息发布点路径


        #region
        /// <summary>
        /// 获取信息发布点路径,不含页面名
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public string GetPubInfoPSNPath(NodeAddionalPubInfo info)
        {
            string strpath = "";
            NodeInfo m_NodeInfo = new NodeInfo();
            NodeManage m_NodeManage = new NodeManage();
            PSNManage m_PSNManage = new PSNManage();          
         
            if (info != null)
            {
                m_NodeInfo = m_NodeManage.GetInfoById(info.NodeId);

                if (info.SelfPSN != "")
                {
                    strpath = m_PSNManage.GetPSNPathByPSN(info.SelfPSN);
                  
                }
                else if (m_NodeInfo != null 
                            && m_NodeInfo.ContentPubTypeId == (int)ContentPubType.EnumElement.StaticPub
                            &&m_NodeInfo.HtmlPSN != "")
                {
                    strpath = m_PSNManage.GetPSNPathByPSN(m_NodeInfo.HtmlPSN);                   
                }
                else if (SYSConfig.SystemVar_DefaultContentPSN != "")
                {
                    strpath = m_PSNManage.GetPSNPathByPSN(SYSConfig.SystemVar_DefaultContentPSN);                  
                }
               
            }
            strpath = strpath.Replace("//", "/");
            return strpath;
        }

        /// <summary>
        /// 获取信息发布点路径,不含页面名
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetPubInfoPSNPath(int id)
        {
            string strpath = "";
            NodeAddionalPubInfo info = GetInfoById(id);        
            NodeInfo m_NodeInfo = new NodeInfo();
            NodeManage m_NodeManage = new NodeManage();
            PSNManage m_PSNManage = new PSNManage();

            if (info != null)
            {
                m_NodeInfo = m_NodeManage.GetInfoById(info.NodeId);

                if (info.SelfPSN != "")
                {
                    strpath = m_PSNManage.GetPSNPathByPSN(info.SelfPSN);

                }
                else if (m_NodeInfo != null
                            && m_NodeInfo.ContentPubTypeId == (int)ContentPubType.EnumElement.StaticPub
                            && m_NodeInfo.HtmlPSN != "")
                {
                    strpath = m_PSNManage.GetPSNPathByPSN(m_NodeInfo.HtmlPSN);
                }
                else if (SYSConfig.SystemVar_DefaultContentPSN != "")
                {
                    strpath = m_PSNManage.GetPSNPathByPSN(SYSConfig.SystemVar_DefaultContentPSN);
                }

            }
            strpath = strpath.Replace("//", "/");
            return strpath;
        }
        #endregion

        #endregion


    }
}

